﻿<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>DR钻戒后台管理系统</title>
    <link rel="stylesheet" href="css/public.css"/>
    <link rel="stylesheet" href="css/style.css"/>
    <script src="../js/jquery-1.12.4.js"></script>
</head>
<script type="text/javascript">

    function LookAdminInfo(id){
        location.href="http://localhost:8080/DiamondRing/back-stage-Management/providerView.html?ID="+id;
        sessionStorage.removeItem("ID");
        sessionStorage.ID=id;
    }

    function UpdateAdminInfo(id){
        location.href="http://localhost:8080/DiamondRing/back-stage-Management/providerUpdate.html?ID="+id;
        sessionStorage.removeItem("ID");
        sessionStorage.ID=id;
    }

    function AddGoods(id,goods){
            if (goods==1){
                alert("该商品已上架")
            }else{
                if (confirm("确定上架该钻戒吗?")){
                location.href="http://localhost:8080/DiamondRing/BackAddGoodsInfoServlet?ID="+id;
            }
        }

    }

    function DelGoods(id,goods){
            if (goods==0){
                alert("该商品已下架")
            }else{
                if (confirm("确定下架该钻戒吗?")){
                location.href="http://localhost:8080/DiamondRing/BackDeleteGoodsInfoServlet?ID="+id;
            }
        }
    }

    $(document).ready(function () {
        $.getJSON("http://localhost:8080/DiamondRing/BackSelectGoodsServlet",function (data) {
            sessionStorage.json=data
            $.each(data,function () {
                $(".providerTable").append("  <tr  id='" + this.id + "' >\n" +
                    "                    <td>"+this.id+"</td>\n" +
                    "                    <td><img width='70px' height='70px' src="+"../"+this.goodsPath+" ></td>\n" +
                    "                    <td>"+this.series+"</td>\n" +
                    "                    <td>"+this.style+"</td>\n" +
                    "                    <td>"+this.type+"</td>\n" +
                    "                    <td>"+this.diamondPrice+"</td>\n" +
                    "                    <td>"+this.sellNum+"</td>\n" +
                    "                    <td>"+this.stock+"</td>\n" +
                    "                    <td>"+this.goods+"</td>\n" +
                    "                    <td>\n" +
                    "                        <a href=\"javascript:void(0)\" onclick='LookAdminInfo("+this.id+")'><img src=\"img/read.png\" alt=\"查看\" title=\"查看\"/></a>\n" +
                    "                        <a href=\"javascript:void(0)\" onclick='UpdateAdminInfo("+this.id+")'><img src=\"img/xiugai.png\" alt=\"修改\" title=\"修改\"/></a>\n" +
                    "                        <a href=\"javascript:void(0)\" onclick='AddGoods("+this.id+","+this.goods+")'>上架</a>\n" +
                    "                        <a href=\"javascript:void(0)\" onclick='DelGoods("+this.id+","+this.goods+")'>下架</a>\n" +
                    "                    </td>\n" +
                    "                </tr>")
            });
        });

        $("#buttons-hbox").click(function () {
            $(".providerTable").empty();
            let name =$("#DRxl").val();
            $.getJSON("http://localhost:8080/DiamondRing/BackVaugeFindServlet","DRxl="+name,function (data) {
                $(".providerTable").append(" <tr class=\"firstTr\">\n" +
                    "                <th width=\"10%\">商品编号</th>\n" +
                    "                <th width=\"10%\">钻戒图片</th>\n" +
                    "                <th width=\"10%\">钻戒系列</th>\n" +
                    "                <th width=\"10%\">钻戒款式</th>\n" +
                    "                <th width=\"5%\">钻戒类型</th>\n" +
                    "                <th width=\"10%\">钻戒价格</th>\n" +
                    "                <th width=\"10%\">售卖数量</th>\n" +
                    "                <th width=\"10%\">库存</th>\n" +
                    "                <th width=\"10%\">上架状态(1:↑ 0:↓)</th>\n" +
                    "                <th width=\"30%\">操作</th>\n" +
                    "            </tr>")
                $.each(data,function () {
                    $(".providerTable").append("  <tr  id='" + this.id + "' >\n" +
                        "                    <td>"+this.id+"</td>\n" +
                        "                    <td><img width='70px' height='70px' src="+"../"+this.goodsPath+" ></td>\n" +
                        "                    <td>"+this.series+"</td>\n" +
                        "                    <td>"+this.style+"</td>\n" +
                        "                    <td>"+this.type+"</td>\n" +
                        "                    <td>"+this.diamondPrice+"</td>\n" +
                        "                    <td>"+this.sellNum+"</td>\n" +
                        "                    <td>"+this.stock+"</td>\n" +
                        "                    <td>"+this.goods+"</td>\n" +
                        "                    <td>\n" +
                        "                        <a href=\"javascript:void(0)\" onclick='LookAdminInfo("+this.id+")'><img src=\"img/read.png\" alt=\"查看\" title=\"查看\"/></a>\n" +
                        "                        <a href=\"javascript:void(0)\" onclick='UpdateAdminInfo("+this.id+")'><img src=\"img/xiugai.png\" alt=\"修改\" title=\"修改\"/></a>\n" +
                        "                        <a href=\"javascript:void(0)\" onclick='AddGoods("+this.id+","+this.goods+")'>上架</a>\n" +
                        "                        <a href=\"javascript:void(0)\" onclick='DelGoods("+this.id+","+this.goods+")'>下架</a>\n" +
                        "                    </td>\n" +
                        "                </tr>")
                });
            });
        })

    })
</script>
<body>
<!--头部-->
<header class="publicHeader">
    <h1>DR钻戒后台管理系统</h1>

    <div class="publicHeaderR">
        <a href="login.html">退出</a>
    </div>
</header>
<!--时间-->
<section class="publicTime">
    <span id="time">2015年1月1日 11:11  星期一</span>
    <a href="#">温馨提示：为了能正常浏览，请使用高版本浏览器!</a>
</section>
<!--主体内容-->
<section class="publicMian ">
    <div class="left">
        <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
        <nav>
            <ul class="list">
                <li><a href="billList.html">订单管理</a></li>
                <li id="active"><a href="providerList.html">商品管理</a></li>
                <li><a href="userList.html">用户管理</a></li>
                <li><a href="password.html">密码修改</a></li>
                <li><a href="login.html">退出系统</a></li>
            </ul>
        </nav>
    </div>
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>供应商管理页面</span>
        </div>
        <div class="search">
            <span>钻戒系列：</span>
            <input type="text" id="DRxl" placeholder="请输入钻戒的系列"/>
            <input type="button" value="查询" id="buttons-hbox"/>
            <a href="providerAdd.html">添加钻戒</a>
        </div>
        <!--供应商操作表格-->
        <table class="providerTable" cellpadding="0" cellspacing="0">
            <tr class="firstTr">
                <th width="10%">商品编号</th>
                <th width="10%">钻戒图片</th>
                <th width="10%">钻戒系列</th>
                <th width="10%">钻戒款式</th>
                <th width="5%">钻戒类型</th>
                <th width="10%">钻戒价格</th>
                <th width="10%">售卖数量</th>
                <th width="10%">库存</th>
                <th width="10%">上架状态(1:↑ 0:↓)</th>
                <th width="30%">操作</th>
            </tr>
        </table>
    </div>
</section>
<footer class="footer">
</footer>

<script src="js/jquery.js"></script>
<script src="js/js.js"></script>
<script src="js/time.js"></script>

</body>
</html>